#ifndef GRAPH_H
#define GRAPH_H



#include "includes.h"
#include "warnings_disable.h"
	#include <qwt_plot.h>
	#include <qwt_plot_marker.h>
	#include <qwt_plot_curve.h>
	#include <qwt_legend.h>
	#include <qwt_data.h>
	#include <qwt_text.h>
#include "warnings_enable.h"



/** @brief Class containing data for drawing graphs
*
*   \image html graph.jpeg
*/
class GraphData: public QwtData
{

public:

	/** @brief Constructor sets array of data
	*	@param d data for graph
	*/
    GraphData( vector< double >* d )
    {
		data = d;
    };

	/** @brief	Copies graph data
	*	@return	pointer to new data
	*/
    virtual QwtData* copy() const
    {
        return new GraphData( data );
    };

	/** @brief	Gets size of array with data
	*	@return size of the array
	*/
    virtual size_t size() const
    {
		return data->size();
    };

	/**	@brief	Function for returning x values
	*	@param	i number to return
	*	@return allways i
	*/
    virtual double x( size_t i ) const
    {
        return i;
    };

	/**	@brief	Function for returning y values
	*	@param	i position of number to return
	*	@return data[ i ], or 0 if out of bounds
	*/
    virtual double y( size_t i ) const
    {
		if ( i < data->size() )
			return ( *data )[ i ];
		else
			return 0;
    };


private:

	//! array of data for graph
	vector< double >* data;

};



/** @brief Class for drawing graphs
*
*   \image html graph.jpeg
*/
class Plot: public QwtPlot
{

public:

	/** @brief Constructor creates graph
	*	@param name name title of the graph
	*	@param axis_x_name title of the x axis
	*	@param axis_y_name title of the y axis
	*	@param show_legend if legend should be generated, or not
	*	@param parent Qt parent
	*/
    Plot( const char* name, const char* axis_x_name, const char* axis_y_name, bool show_legend = true, QWidget* parent = 0 );

	//! @brief Deletes plot marker and legend
	~Plot();


private:

	//! zero line
	QwtPlotMarker* mY;
	//! curves legend
	QwtLegend* legend;

};



#endif